\ Speech API Test
\ Tom Dixon
\ 9/8/2008

\ This is a text-to-speech example of COM.  It has limited
\ practical use, but is fun to play with.

include FCOMbase.bld

also FCOM

\ SAPI 5.0 typelibrary
5 0 typelib {C866CA3A-32F7-11D2-9602-00C04F8EE628}

\ ISPVoice Interface Instance
ISpVoice ComIFace voice

\ Create voice instance
: Voice-Init ( -- )
   com_init
   voice ISpVoice 1 0 SpVoice fCoCreateInstance
   abort" Unable to get ISpVoice Interface!" ;

: voice? ( -- )
  voice @ 0= abort" Voice object not Initialized!" ;

: speak ( str len -- )
   voice? >unicode drop 0 SVSFlagsAsync rot voice speak drop ;

: VoiceSpeed! ( n -- )
   voice? voice setrate drop ;

: VoiceSpeed@ ( -- n )
   voice? pad voice getrate drop pad @ ;

: VoiceVol! ( n -- )
   voice? voice setVolume drop ;

: VoiceVol@ ( -- n )
   voice? pad voice getVolume drop pad @ ;

: VoicePause ( -- )
   voice? voice pause drop ;

: VoiceResume ( -- )
   voice? voice resume drop ;

: VoiceStop ( -- )
   voice? 0 SVSFPurgeBeforeSpeak u" " drop voice speak drop ;

: VoiceWait ( n -- ) \ waits until speaking is done or n miliseconds have passed
   voice? voice WaitUntilDone drop ;

: Voice-Close ( -- ) \ cleanup everything
   voice? voice release drop 0 voice ! ;


free-lasttypelib
previous


